<?php
/**
  * FAQ修改
  * faqEdit.php
  * 模板文件：faqEdit.html
  */
include_once("global.php");
include_once("functions/faq.class.php");
include_once("lang/".$CONFIG->lang."/faq.lang.php");

$faq = new faq;

//$DB->debug = true;
//取得参数
$fiId 		= $_REQUEST["fiid"];//faq id
$question 	= trim($_REQUEST["question"]);
$reply		= trim($_REQUEST["reply"]);
$fiType		= $_REQUEST["fiType"];
$act		= $_REQUEST["act"];

$errmsg = "";
if($act == "edit"){
	if(empty($question))	$errmsg .= $lang["question_cannot_null"];
	if(empty($reply))	$errmsg .= $lang["reply_cannot_null"];
	if(empty($fiType))	$errmsg .= $lang["type_cannot_null"];
}

if($act == "edit" && $errmsg == ""){
	if($faq->edit($question, $reply, $fiType,$fiId ))
	$errmsg = $lang["edit_success"];
}
//根据id取得该条faq的详细信息
$rs = $faq->getById($fiId);
$question 		= $rs->fields["fi_question"];
$reply 			= $rs->fields["fi_reply"];
$fiType 		= $rs->fields["fi_type"];
//模板设置
$smarty = $COMMON->template_init();

$smarty -> assign(array(
			"errmsg"		=> $errmsg,
			"op_id"			=> $GLOBAL["OP_ID"],
			"question"		=> $question,
			"reply"			=> $reply,
			"fiid"			=> $fiId,
			"fitypeOption"	=> $COMMON->getOptionsString($GLOBAL["DATA"]->faqType, $fiType),
		));

$smarty->display("faqEdit.html");
?>